package com.yonhee.arithmetic.recursion;

public class Factorial {
    public static void main(String[] args) {
        int result = factorial(10);
        System.out.println("-------------");
        System.out.println(result);
    }

    public static int factorial(int n) {
        if (n < 0) {
            throw new IllegalArgumentException("非法参数");
        }
        if (n == 1 || n == 0) {
            return 1;
        }
        int temp = n * factorial(n - 1);
        System.out.println(temp);
        return temp;
    }
}
